﻿using System;
using System.Collections.Generic;

using DataFactory.Cms;
using IDAL.Cms;
using Model.Cms;
using Model.Base;
using Model.AuthModel;
namespace BLL.Cms
{
    /// <summary>
    /// 业务层，内容管理，下载资源
    /// </summary>
    public class ResourceBLL
    {
        /// <summary>
        /// 资源映射
        /// </summary>
        private IResource dal = DataAccess.CreateResource();

        /// <summary>
        /// 新增资源
        /// </summary>
        /// <param name="resourceType">资源类别</param>
        /// <param name="resourceName">资源名</param>
        /// <param name="resourceLink">链接</param>
        /// <param name="contentSize">尺寸</param>
        /// <param name="contentType">类型</param>
        /// <param name="contentExtension">扩展名</param>
        /// <param name="staff">管理员</param>
        /// <param name="isOnline">是否上线</param>
        /// <param name="onlineTime">上线时间</param>
        /// <returns></returns>
        public bool InsertResource(int resourceType, string resourceName, string resourceLink, string contentSize, string contentType, string contentExtension
            , StaffInfo staff, string isOnline, DateTime onlineTime) 
        {
            ResourceInfo info = new ResourceInfo();
            info.ResourceType = new Model.Config.TermInfo();
            info.ResourceType.TermID = resourceType;
            info.ResourceName = resourceName;
            info.ResourceLink = resourceLink;
            info.ContentSize = contentSize;
            info.ContentType = contentType;
            info.ContentExtension = contentExtension;
            info.Staff = staff;
            info.IsOnline = isOnline;
            info.OnlineTime = onlineTime;
            return dal.InsertResource(info);
        }

        /// <summary>
        /// 修改资源
        /// </summary>
        /// <param name="resourceID">资源编号</param>
        /// <param name="resourceType">资源类别</param>
        /// <param name="resourceName">资源名</param>
        /// <param name="resourceLink">链接</param>
        /// <param name="contentSize">尺寸</param>
        /// <param name="contentType">类型</param>
        /// <param name="contentExtension">扩展名</param>
        /// <param name="staff">管理员</param>
        /// <param name="isOnline">是否上线</param>
        /// <param name="onlineTime">上线时间</param>
        /// <returns></returns>
        public bool UpdateResource(int resourceID, int resourceType, string resourceName, string resourceLink, string contentSize, string contentType, string contentExtension
            , StaffInfo staff, string isOnline, DateTime onlineTime)
        {
            ResourceInfo info = new ResourceInfo();
            info.ResourceID = resourceID;
            info.ResourceType = new Model.Config.TermInfo();
            info.ResourceType.TermID = resourceType;
            info.ResourceName = resourceName;
            info.ResourceLink = resourceLink;
            info.ContentSize = contentSize;
            info.ContentType = contentType;
            info.ContentExtension = contentExtension;
            info.Staff = staff;
            info.IsOnline = isOnline;
            info.OnlineTime = onlineTime;
            return dal.InsertResource(info);
        }

        /// <summary>
        /// 根据编号获取资源
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ResourceInfo GetResourceByID(int id) 
        {
            return dal.GetResourceByID(id);
        }
    }
}
